
<template>

  <div>

    <input v-model="entity.nikename" value="entity.nikename"><el-button @click="add()">新增</el-button>

     <el-table :data="list" style="width: 100%">
        <el-table-column prop="nikename" label="姓名" width="180"></el-table-column>
        <el-table-column prop="name" label="账号" width="180"></el-table-column>

    </el-table>
  </div>
    
</template>
<script>
import userApi from '@/api/user'
export default {
    data(){
        return {
            list:[],
            entity: {
            }
        }
    },
    created(){
        this.fetchData();
    },
    methods:{
        fetchData(){
            userApi.findAll().then(response => {
              this.entity = {};
                this.list=response.data;
            });
        },
        add(){
          userApi.add(this.entity).then(response =>{
            this.fetchData();
          })
        }
    }
}
</script>